package testset;

import java.io.IOException;
import java.net.MalformedURLException;

import lv.rtu.ditf.dc.fs.CategoryFormatException;
import lv.rtu.ditf.dc.fs.DocumentCategory;
import lv.rtu.ditf.dc.fs.FileStorage;
import lv.rtu.ditf.dc.url.PlainTextPageLoader;
import lv.rtu.ditf.dc.url.UnsupportedContentTypeException;

/**
 * 
 * @author Pāvels Koliškins, Edgars Matisāns
 *
 */
public class TestSetGeneration {
    public static void main(String args[]) throws IOException, MalformedURLException, UnsupportedContentTypeException, CategoryFormatException {
        FileStorage fileStorage = FileStorage.get();
        
        String[] categories = new String[] {"Sports", "Medicīna", "IT", "Kultūra"};
        for (String category : categories) {
            fileStorage.createDocumentCategory(category);
        }

        String[][] categoryFiles = new String[][] {
            {"http://www.delfi.lv", "http://www.ss.lv"},
            {"http://www.apollo.lv"},
            {"http://www.rtu.lv"},
            {"http://www.google.lv"}
        };

        for (int i = 0; i < categoryFiles.length; i++) {
            DocumentCategory category = fileStorage.getDocumentCategory(categories[i]);
            for (String categoryFile : categoryFiles[i]) {

                category.addDocument(PlainTextPageLoader.loadPage(categoryFile));

            }
        }


    }
}
